add_library(ETHERNET_FILES STATIC)

target_sources(ETHERNET_FILES PUBLIC
    ${WIZNET_DIR}/Ethernet/socket.c
    ${WIZNET_DIR}/Ethernet/wizchip_conf.c
)

target_include_directories(ETHERNET_FILES INTERFACE
    ${WIZNET_DIR}/Ethernet
    ${WIZNET_DIR}/Ethernet/W6100
)

target_link_libraries(ETHERNET_FILES PUBLIC
    W6100_FILES
)

add_library(W6100_FILES STATIC)

target_sources(W6100_FILES PUBLIC
        ${WIZNET_DIR}/Ethernet/W6100/w6100.c
)

target_include_directories(W6100_FILES INTERFACE
        ${WIZNET_DIR}/Ethernet
        ${WIZNET_DIR}/Ethernet/W6100
)

target_link_libraries(W6100_FILES PRIVATE
        ETHERNET_FILES
)

# Add dhcpv4 related libraries
add_library(DHCP_FILES STATIC)
target_sources(DHCP_FILES PUBLIC
        ${WIZNET_DIR}/Internet/DHCP4/dhcpv4.c
)
target_include_directories(DHCP_FILES INTERFACE
        ${WIZNET_DIR}/Internet
        ${WIZNET_DIR}/Internet/DHCP4
)
target_link_libraries(DHCP_FILES PRIVATE
        ETHERNET_FILES
)

# Add dns related libraries
add_library(DNS_FILES STATIC)
target_sources(DNS_FILES PUBLIC
        ${WIZNET_DIR}/Internet/DNS/dns.c
)
target_include_directories(DNS_FILES INTERFACE
        ${WIZNET_DIR}/Internet 
        ${WIZNET_DIR}/Internet/DNS 
)
target_link_libraries(DNS_FILES PRIVATE
        ETHERNET_FILES
)


add_library(APP_FILES STATIC)
target_sources(APP_FILES PUBLIC
        ${WIZNET_DIR}/Application/loopback/loopback.c
        ${WIZNET_DIR}/Application/multicast/multicast.c
)
target_include_directories(APP_FILES INTERFACE
        ${WIZNET_DIR}/Application 
        ${WIZNET_DIR}/Application/loopback 
        ${WIZNET_DIR}/Application/multicast 
)
target_link_libraries(APP_FILES PRIVATE
        ETHERNET_FILES
)